import { getReceiveAssetListApi } from '@/api/task/task'

// 获取可领用资产列表hooks
export default function useGetReceiveAssetList() {
  const receiveOptions = ref([])
  const receiveLoading = ref(false)
  const { userInfo } = getUserInfo()

  const fetchGetReceiveList = async (isUserId = false, typeId?: number) => {
    receiveLoading.value = true
    // 是否使用isUser过滤
    const res = await getReceiveAssetListApi({
      isUserId,
      orgId: userInfo.value.orgId as number,
      typeId: typeId
    })
    if (res.code === '0000') {
      receiveOptions.value = res.data
    }
    receiveLoading.value = false
  }

  fetchGetReceiveList()

  return {
    fetchGetReceiveList,
    receiveOptions,
    receiveLoading
  }
}
